Optimal. Leaf size=164 \[ \frac {(b B-2 a C) \tanh ^{-1}(\sin (c+d x))}{b^3 d}-\frac {2 a \left (a^2 b B-2 b^3 B-2 a^3 C+3 a b^2 C\right ) \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{(a-b)^{3/2} b^3 (a+b)^{3/2} d}+\frac {C \tan (c+d x)}{b^2 d}-\frac {a^2 (b B-a C) \tan (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \sec (c+d x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.46, antiderivative size = 164, normalized size of antiderivative = 1.00, number of steps
used = 8, number of rules used = 8, integrand size = 40, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {4157, 4113,
4167, 4083, 3855, 3916, 2738, 214} \begin {gather*} -\frac {a^2 (b B-a C) \tan (c+d x)}{b^2 d \left (a^2-b^2\right ) (a+b \sec (c+d x))}-\frac {2 a \left (-2 a^3 C+a^2 b B+3 a b^2 C-2 b^3 B\right ) \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{b^3 d (a-b)^{3/2} (a+b)^{3/2}}+\frac {(b B-2 a C) \tanh ^{-1}(\sin (c+d x))}{b^3 d}+\frac {C \tan (c+d x)}{b^2 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 214
Rule 2738
Rule 3855
Rule 3916
Rule 4083
Rule 4113
Rule 4157
Rule 4167
Rubi steps
\begin {align*} \int \frac {\sec ^2(c+d x) \left (B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+b \sec (c+d x))^2} \, dx &=\int \frac {\sec ^3(c+d x) (B+C \sec (c+d x))}{(a+b \sec (c+d x))^2} \, dx\\ &=-\frac {a^2 (b B-a C) \tan (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \sec (c+d x))}-\frac {\int \frac {\sec (c+d x) \left (-a b (b B-a C)-\left (a^2-b^2\right ) (b B-a C) \sec (c+d x)-b \left (a^2-b^2\right ) C \sec ^2(c+d x)\right )}{a+b \sec (c+d x)} \, dx}{b^2 \left (a^2-b^2\right )}\\ &=\frac {C \tan (c+d x)}{b^2 d}-\frac {a^2 (b B-a C) \tan (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \sec (c+d x))}-\frac {\int \frac {\sec (c+d x) \left (-a b^2 (b B-a C)-b \left (a^2-b^2\right ) (b B-2 a C) \sec (c+d x)\right )}{a+b \sec (c+d x)} \, dx}{b^3 \left (a^2-b^2\right )}\\ &=\frac {C \tan (c+d x)}{b^2 d}-\frac {a^2 (b B-a C) \tan (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \sec (c+d x))}+\frac {(b B-2 a C) \int \sec (c+d x) \, dx}{b^3}-\frac {\left (a \left (a^2 b B-2 b^3 B-2 a^3 C+3 a b^2 C\right )\right ) \int \frac {\sec (c+d x)}{a+b \sec (c+d x)} \, dx}{b^3 \left (a^2-b^2\right )}\\ &=\frac {(b B-2 a C) \tanh ^{-1}(\sin (c+d x))}{b^3 d}+\frac {C \tan (c+d x)}{b^2 d}-\frac {a^2 (b B-a C) \tan (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \sec (c+d x))}-\frac {\left (a \left (a^2 b B-2 b^3 B-2 a^3 C+3 a b^2 C\right )\right ) \int \frac {1}{1+\frac {a \cos (c+d x)}{b}} \, dx}{b^4 \left (a^2-b^2\right )}\\ &=\frac {(b B-2 a C) \tanh ^{-1}(\sin (c+d x))}{b^3 d}+\frac {C \tan (c+d x)}{b^2 d}-\frac {a^2 (b B-a C) \tan (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \sec (c+d x))}-\frac {\left (2 a \left (a^2 b B-2 b^3 B-2 a^3 C+3 a b^2 C\right )\right ) \text {Subst}\left (\int \frac {1}{1+\frac {a}{b}+\left (1-\frac {a}{b}\right ) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{b^4 \left (a^2-b^2\right ) d}\\ &=\frac {(b B-2 a C) \tanh ^{-1}(\sin (c+d x))}{b^3 d}-\frac {2 a \left (a^2 b B-2 b^3 B-2 a^3 C+3 a b^2 C\right ) \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{(a-b)^{3/2} b^3 (a+b)^{3/2} d}+\frac {C \tan (c+d x)}{b^2 d}-\frac {a^2 (b B-a C) \tan (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \sec (c+d x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 2.34, size = 240, normalized size = 1.46 \begin {gather*} \frac {-\frac {2 a \left (-a^2 b B+2 b^3 B+2 a^3 C-3 a b^2 C\right ) \tanh ^{-1}\left (\frac {(-a+b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-b B \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+2 a C \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+b B \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )-2 a C \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+\frac {a^2 b (-b B+a C) \sin (c+d x)}{(a-b) (a+b) (b+a \cos (c+d x))}+b C \tan (c+d x)}{b^3 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.41, size = 245, normalized size = 1.49
method | result | size |
derivativedivides | \(\frac {-\frac {C}{b^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}+\frac {\left (-b B +2 a C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{b^{3}}-\frac {C}{b^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}+\frac {\left (b B -2 a C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{b^{3}}+\frac {2 a \left (\frac {a b \left (b B -a C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (a^{2}-b^{2}\right ) \left (a \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-b \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-a -b \right )}-\frac {\left (a^{2} b B -2 b^{3} B -2 a^{3} C +3 C \,b^{2} a \right ) \arctanh \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{\left (a +b \right ) \left (a -b \right ) \sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{b^{3}}}{d}\) | \(245\) |
default | \(\frac {-\frac {C}{b^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}+\frac {\left (-b B +2 a C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{b^{3}}-\frac {C}{b^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}+\frac {\left (b B -2 a C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{b^{3}}+\frac {2 a \left (\frac {a b \left (b B -a C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (a^{2}-b^{2}\right ) \left (a \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-b \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-a -b \right )}-\frac {\left (a^{2} b B -2 b^{3} B -2 a^{3} C +3 C \,b^{2} a \right ) \arctanh \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{\left (a +b \right ) \left (a -b \right ) \sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{b^{3}}}{d}\) | \(245\) |
risch | \(\frac {2 i \left (B a \,b^{2} {\mathrm e}^{3 i \left (d x +c \right )}-C \,a^{2} b \,{\mathrm e}^{3 i \left (d x +c \right )}+B \,a^{2} b \,{\mathrm e}^{2 i \left (d x +c \right )}-2 C \,a^{3} {\mathrm e}^{2 i \left (d x +c \right )}+C a \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+B a \,b^{2} {\mathrm e}^{i \left (d x +c \right )}-3 C \,a^{2} b \,{\mathrm e}^{i \left (d x +c \right )}+2 b^{3} C \,{\mathrm e}^{i \left (d x +c \right )}+a^{2} b B -2 a^{3} C +C \,b^{2} a \right )}{d \,b^{2} \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) \left (-a^{2}+b^{2}\right ) \left (a \,{\mathrm e}^{2 i \left (d x +c \right )}+2 b \,{\mathrm e}^{i \left (d x +c \right )}+a \right )}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B}{b^{2} d}-\frac {2 a C \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{b^{3} d}+\frac {a^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) B}{\sqrt {a^{2}-b^{2}}\, \left (a +b \right ) \left (a -b \right ) d \,b^{2}}-\frac {2 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) B}{\sqrt {a^{2}-b^{2}}\, \left (a +b \right ) \left (a -b \right ) d}-\frac {2 a^{4} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) C}{\sqrt {a^{2}-b^{2}}\, \left (a +b \right ) \left (a -b \right ) d \,b^{3}}+\frac {3 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) C}{\sqrt {a^{2}-b^{2}}\, \left (a +b \right ) \left (a -b \right ) d b}-\frac {a^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) B}{\sqrt {a^{2}-b^{2}}\, \left (a +b \right ) \left (a -b \right ) d \,b^{2}}+\frac {2 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) B}{\sqrt {a^{2}-b^{2}}\, \left (a +b \right ) \left (a -b \right ) d}+\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) a^{4} C}{\sqrt {a^{2}-b^{2}}\, \left (a +b \right ) \left (a -b \right ) d \,b^{3}}-\frac {3 \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) C \,a^{2}}{\sqrt {a^{2}-b^{2}}\, \left (a +b \right ) \left (a -b \right ) d b}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B}{b^{2} d}+\frac {2 a C \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{b^{3} d}\) | \(977\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 529 vs.
\(2 (157) = 314\).
time = 19.92, size = 1114, normalized size = 6.79 \begin {gather*} \left [\frac {{\left ({\left (2 \, C a^{5} - B a^{4} b - 3 \, C a^{3} b^{2} + 2 \, B a^{2} b^{3}\right )} \cos \left (d x + c\right )^{2} + {\left (2 \, C a^{4} b - B a^{3} b^{2} - 3 \, C a^{2} b^{3} + 2 \, B a b^{4}\right )} \cos \left (d x + c\right )\right )} \sqrt {a^{2} - b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) - {\left (a^{2} - 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, \sqrt {a^{2} - b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )} \sin \left (d x + c\right ) + 2 \, a^{2} - b^{2}}{a^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + b^{2}}\right ) - {\left ({\left (2 \, C a^{6} - B a^{5} b - 4 \, C a^{4} b^{2} + 2 \, B a^{3} b^{3} + 2 \, C a^{2} b^{4} - B a b^{5}\right )} \cos \left (d x + c\right )^{2} + {\left (2 \, C a^{5} b - B a^{4} b^{2} - 4 \, C a^{3} b^{3} + 2 \, B a^{2} b^{4} + 2 \, C a b^{5} - B b^{6}\right )} \cos \left (d x + c\right )\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) + {\left ({\left (2 \, C a^{6} - B a^{5} b - 4 \, C a^{4} b^{2} + 2 \, B a^{3} b^{3} + 2 \, C a^{2} b^{4} - B a b^{5}\right )} \cos \left (d x + c\right )^{2} + {\left (2 \, C a^{5} b - B a^{4} b^{2} - 4 \, C a^{3} b^{3} + 2 \, B a^{2} b^{4} + 2 \, C a b^{5} - B b^{6}\right )} \cos \left (d x + c\right )\right )} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (C a^{4} b^{2} - 2 \, C a^{2} b^{4} + C b^{6} + {\left (2 \, C a^{5} b - B a^{4} b^{2} - 3 \, C a^{3} b^{3} + B a^{2} b^{4} + C a b^{5}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{2 \, {\left ({\left (a^{5} b^{3} - 2 \, a^{3} b^{5} + a b^{7}\right )} d \cos \left (d x + c\right )^{2} + {\left (a^{4} b^{4} - 2 \, a^{2} b^{6} + b^{8}\right )} d \cos \left (d x + c\right )\right )}}, \frac {2 \, {\left ({\left (2 \, C a^{5} - B a^{4} b - 3 \, C a^{3} b^{2} + 2 \, B a^{2} b^{3}\right )} \cos \left (d x + c\right )^{2} + {\left (2 \, C a^{4} b - B a^{3} b^{2} - 3 \, C a^{2} b^{3} + 2 \, B a b^{4}\right )} \cos \left (d x + c\right )\right )} \sqrt {-a^{2} + b^{2}} \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )}}{{\left (a^{2} - b^{2}\right )} \sin \left (d x + c\right )}\right ) - {\left ({\left (2 \, C a^{6} - B a^{5} b - 4 \, C a^{4} b^{2} + 2 \, B a^{3} b^{3} + 2 \, C a^{2} b^{4} - B a b^{5}\right )} \cos \left (d x + c\right )^{2} + {\left (2 \, C a^{5} b - B a^{4} b^{2} - 4 \, C a^{3} b^{3} + 2 \, B a^{2} b^{4} + 2 \, C a b^{5} - B b^{6}\right )} \cos \left (d x + c\right )\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) + {\left ({\left (2 \, C a^{6} - B a^{5} b - 4 \, C a^{4} b^{2} + 2 \, B a^{3} b^{3} + 2 \, C a^{2} b^{4} - B a b^{5}\right )} \cos \left (d x + c\right )^{2} + {\left (2 \, C a^{5} b - B a^{4} b^{2} - 4 \, C a^{3} b^{3} + 2 \, B a^{2} b^{4} + 2 \, C a b^{5} - B b^{6}\right )} \cos \left (d x + c\right )\right )} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (C a^{4} b^{2} - 2 \, C a^{2} b^{4} + C b^{6} + {\left (2 \, C a^{5} b - B a^{4} b^{2} - 3 \, C a^{3} b^{3} + B a^{2} b^{4} + C a b^{5}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{2 \, {\left ({\left (a^{5} b^{3} - 2 \, a^{3} b^{5} + a b^{7}\right )} d \cos \left (d x + c\right )^{2} + {\left (a^{4} b^{4} - 2 \, a^{2} b^{6} + b^{8}\right )} d \cos \left (d x + c\right )\right )}}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\left (B + C \sec {\left (c + d x \right )}\right ) \sec ^{3}{\left (c + d x \right )}}{\left (a + b \sec {\left (c + d x \right )}\right )^{2}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 404 vs.
\(2 (157) = 314\).
time = 0.49, size = 404, normalized size = 2.46 \begin {gather*} \frac {\frac {2 \, {\left (2 \, C a^{4} - B a^{3} b - 3 \, C a^{2} b^{2} + 2 \, B a b^{3}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {-a^{2} + b^{2}}}\right )\right )}}{{\left (a^{2} b^{3} - b^{5}\right )} \sqrt {-a^{2} + b^{2}}} - \frac {2 \, {\left (2 \, C a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - B a^{2} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - C a^{2} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - C a b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + C b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 2 \, C a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + B a^{2} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - C a^{2} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + C a b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + C b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} - 2 \, a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + a + b\right )} {\left (a^{2} b^{2} - b^{4}\right )}} - \frac {{\left (2 \, C a - B b\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{b^{3}} + \frac {{\left (2 \, C a - B b\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{b^{3}}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 12.68, size = 2500, normalized size = 15.24 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________